/*
 * SGX Public License Notice This software is the intellectual property of SGX.
 * The program may be used only in accordance with the terms of the license
 * agreement you entered into with SGX. 2003 Singapore Exchange Pte Ltd (SGX).
 * All rights reserved. 2 Shenton Way / #22-00 SGX Centre 1 Singapore( 068804 )
 */
package com.hbyj.gps;

/**
 * @author John
 * @since Jul 30, 2010
 */
import java.util.Observable;
import java.util.Observer;

public class CommDataObserver implements Observer
{
    String name;
    String jd,wd;

    public CommDataObserver( String name )
    {
        this.name = name;
    }

    public void update( Observable o, Object arg )
    {
     //   System.out.println("读取到的数据位数："+(( byte[] ) arg).length);
     //   System.out.println( "[" + name + "] GetMessage:\n ["
       //     + new String( ( byte[] ) arg ) + "]" );
   /* 	String tmp = new String((byte[])arg);
    	String gprmcstr = parserNEMA(tmp);
    	GpsJWInfo gpsinfo = new GpsJWInfo();
    	gpsinfo = createGPSData(gprmcstr);
    	this.jd = String.valueOf(gpsinfo.plon);
    	this.wd =  String.valueOf(gpsinfo.plat);
    	System.out.println("读取到的经纬度："+"["+gpsinfo.plon+","+gpsinfo.plat+"]");
    */
    }
    
    //解析NEMA数据
  /*  public String parserNEMA(String msgStr)
    {
    	int pos = msgStr.indexOf("$GPRMC");
    	String gprmcStr = (pos>-1)?msgStr.substring(pos):null;
    	String gprmc = gprmcStr;
    	if(gprmcStr != null){
    		gprmcStr= gprmcStr.substring(0,70);
    		
    		int pos2 = gprmcStr.indexOf("$", 1);
    		gprmc = (pos2>-1)?gprmcStr.substring(0,pos2-1):gprmcStr;	
    	} 	
    	return gprmc;
    }
      
    public GpsJWInfo createGPSData(String gprmcStr)
    {
    	float fplat,fplon;
    	int degree;
    	if(gprmcStr==null)
    		return null;
    	GpsJWInfo gpsinfo = new GpsJWInfo();
    	String[] source = gprmcStr.split("$GPRMC");
    	if(source !=null && source.length>=12)
    	{
    		if(source[4].length()>0 && source[3].length()>2)
    		{
    			gpsinfo.plat = Float.valueOf(source[3]);  
    		}
    		else
    		{
    			gpsinfo.plat= 0;
    		}
    		//经度  
    		if (source[6].length() > 0 && source[5].length() > 3)  
            {  
    			gpsinfo.plon = Float.valueOf(source[5]); 
    		}  
    		else  
    		{  
    			gpsinfo.plon= 0;  
    		}  
    	}
    	//转换成度
    	degree = (int)gpsinfo.plat/100;
    	fplat = degree+(gpsinfo.plat-degree*100)/60;
    	degree = (int)gpsinfo.plon/100;
    	fplon = degree+(gpsinfo.plon-degree*100)/60;
    	gpsinfo.plat = fplat;
    	gpsinfo.plon = fplon;
    	return gpsinfo;	
    }
    
    public String GetJWD(){
    	
    	String jwd = this.jd+","+this.wd;
    	return jwd;
    }*/
}
